package com.nfIt.th02;

/**
 * ClossName:Account
 * Pakage:com.nfIt
 * Description
 *
 * @Author L
 * @Create 2024/5/12 9:20
 * @Version 2023.1.3
 * 账户类
 */
public class Account{

    /**
     * 表示账户余额。
     */
    private Double balance;

    public Account(Double balance) {
        this.balance = balance;
    }

    /**
     * 用于存款
     * @param amount 要存款参数
     * @return 存款余额
     */
    public Double deposit(Double amount){
        return balance+=amount;
    }

    /**
     * 用于取款
     * @param amount
     * @return
     */
   public Double withdraw(double amount){

     if (balance <= 0){
         return 0d;
     }
     return  balance-=amount;
   }


}
